package com.bruan.regex;

import java.util.Scanner;

public class RegexTest2 {
    public static void main(String[] args) {
//        checkPhone();
//        checkEmail();
        checkTime();
    }

    public static void checkPhone(){
        System.out.println("请输入号码");
        Scanner sc = new Scanner(System.in);
        while (true) {
            String phone = sc.next();
            if (phone.matches("(1[3-9]\\d{9})|(0\\d{2,7}-?[1-9]\\d{4,19})")){
                System.out.println("格式正确");
                break;
            }else {
                System.out.println("格式错误! 请重试");
            }
        }
    }
    public static void checkEmail(){
        System.out.println("请输入Email");
        Scanner sc = new Scanner(System.in);
        while (true) {
            String phone = sc.next();
            if (phone.matches("\\w{2,}@\\w{2,20}(\\.\\w{2,10}){1,2}")){
                System.out.println("格式正确");
                break;
            }else {
                System.out.println("格式错误! 请重试");
            }
        }
    }
    public static void checkTime(){
        System.out.println("请输入时间");
        Scanner sc = new Scanner(System.in);
        while (true){
            String time = sc.next();

//           2024/3/1
            if(time.matches("//d{4}//[1-12]//[1-12]")){
                System.out.println("true");
                break;
            }else {
                System.out.println("false");
            }
        }
    }
}


